Why Swipe left doesn't work? [on hold]

Posted by Hitesh on Game Development See other posts from Game Development or by Hitesh
Published on 2014-05-27T10:21:15Z Indexed on 2014/05/27 22:19 UTC
Read the original article Hit count: 253

Filed under:
|

I wrote the below code to detect and perform a sprite action on the single tap and swipe right event.

@Override
public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
    float x = 0F;
    int tapCount = 0;
    boolean playermoving = false;
    // TODO Auto-generated method stub
    if (pSceneTouchEvent.getAction() == MotionEvent.ACTION_MOVE) {
        if (pSceneTouchEvent.getX() > x) {
            playermoving = true;
            players.runRight();
        }
        if (pSceneTouchEvent.getX() < x) {

            Log.i("Run Left", "SPRITE Left");
        }
        /*
         * if (pSceneTouchEvent.getX() < x) { System.exit(0);
         * Log.i("SWIPE left", "SPRITE LEFT"); }
         */
    }
    if (pSceneTouchEvent.getAction() == MotionEvent.ACTION_DOWN) {
        playermoving = false;
        x = pSceneTouchEvent.getX();
        tapCount++;
        Log.i("X CORD", String.valueOf(x));
    }
    if (pSceneTouchEvent.isActionDown()) {
        if (tapCount == 1 && playermoving != true) {
            tapCount = 0;
            players.jumpRight();

        }
    }
    return true;
}

The code works fine. The only problem is that the swipe left event is not being detected due to some reasons. What can i do to make the swipe left action work? Please help

© Game Development or respective owner

Related posts about android

Related posts about andengine